<!DOCTYPE html>
<html lang="zh">

<head>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>页面</title>
    <script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/loading.js"></script>
    <link href="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/theme-chalk/index.css" rel="stylesheet">

</head>

<style>
    .spacing {
        height: 60px;
    }
</style>
<body>
<div id="app">
    <el-container>
        <el-main>
        <el-header>
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">PM订单管理</el-breadcrumb-item>
                <el-breadcrumb-item>订单列表</el-breadcrumb-item>
            </el-breadcrumb>
        </el-header>
            <el-row :gutter="20" style="margin-left: 0;margin-right: 0">
                <el-col :xs="14" :sm="14" :md="8" :lg="8" :xl="8">
                    <el-input placeholder="请输入内容" @keyup.enter.native="enterSearch" v-model="keySearch"
                              style="width: 100%">
                        <el-button slot="append" icon="el-icon-search" @click=search></el-button>
                    </el-input>
                </el-col>
            </el-row>
            <el-table :data="tableData" stripe border style="width:100%" highlight-current-row size="mini"
                      tooltip-effect="dark">
            <#--<el-table-column prop="orderBean_pk" label="序号" align="center" width="50px">-->
            <#--</el-table-column>-->
                　　
                <el-table-column prop="code" label="订单编号" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                <el-table-column prop="project.name" label="项目名称" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                　　
                <el-table-column prop="orderDate" label="订单日期" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                <el-table-column prop="orderAmount" label="订单金额（元）" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                <el-table-column prop="status" label="订单状态" align="center" :formatter="formatStatus"
                                 :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                　
                　　
                <el-table-column label="操作" align="center" min-width="140" fixed="right">
                    　　　　
                    <template slot-scope="scope">
                    <#--　　　　　<template v-for="item in button">-->
                    <#--<el-button type="text" @click="item.fn(scope.row.id)">{{item.name}}</el-button>-->
                    <#--</template>-->
                        　　　　　
                        <el-button type="text"
                                   @click="detail(scope.row.id,scope.row.purchaseOrderName,scope.row.code,scope.row.project.name,scope.row.buyer.realname,scope.row.deliveryAddress,scope.row.comment,scope.row.orderDate,scope.row.orderAmount,scope.row.supplierContactPhone)">
                            查看
                        </el-button>
                        <el-button type="text" v-if="scope.row.status==99"
                                   @click="submit(scope.row.id,scope.row.purchaseOrderName,scope.row.code,scope.row.project.name,scope.row.buyer.realname,scope.row.deliveryAddress,scope.row.comment,scope.row.orderAmount,scope.row.supplierContactPhone)">
                            导入
                        </el-button>
                        　　　　
                    </template>
                    　　
                </el-table-column>
            </el-table>
        </el-main>
        <el-footer>
            <el-row>
                <el-col>
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                   :page-sizes="[10, 20, 50, 100]" :page-size="pageSize"
                                   layout="total, sizes, prev, pager, next, jumper"
                                   :total="totalRecords">
                    </el-pagination>
                </el-col>
            </el-row>
        </el-footer>
    </el-container>
</div>

<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/dist/vue.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/index.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/publiccss/assets/global/plugins/jquery.min.js"
        type="text/javascript"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                dialogFormVisible: false,
                dialogVisible: false,
                keySearch: '',
                tableData: [],
                currentPage: 1, //当前页
                pageSize: 10, //每页总数
                totalRecords: 0, //总条数
            <#--button:'${operaButton}',-->
            };
        },

        methods: {
            //状态转换
            formatStatus: function (row, column) {
                return row.status == 11 ? '已导入' : row.status == 99 ? '未导入' : '未知';
            },
            //回车监听事件获取输入内容
            enterSearch: function (event) {
                this.keySearch = event.target.value;
                this.ajaxFunction()
            },
            search() {
                //声明要发送的参数
                this.ajaxFunction();
            },
            //查看详情
            detail(dataId, order_name, surface_id, project_name, buyer, consignee_address, remark, crtTime, price,consignee_information) {
                window.location.href = "/order/detailOrderByPM.page?dataId=" + dataId + "&order_name=" + order_name + "&surface_id=" + surface_id + "&project_name=" + project_name +
                        "&buyer=" + buyer + "&consignee_address=" + consignee_address + "&remark=" + remark + "&crtTime=" + crtTime + "&price=" + price+"&consignee_information="+consignee_information;
            },
            async handleSizeChange(val) {
                this.pageSize = val;
                this.ajaxFunction();
            },
            async handleCurrentChange(val) {
                this.currentPage = val;
                this.ajaxFunction();
            },
            submit(dataId, order_name, surface_id, project_name, buyer, consignee_address, remark,price,consignee_information) {
                //声明要发送的参数
                var bool = false;
                var err = "系统异常！";
                $.ajax({
                    url: '/order/submitOrderByPM.json',
                    type: 'post',
                    data: {
                        dataId: dataId,
                        order_name: order_name,
                        surface_id: surface_id,
                        project_name: project_name,
                        buyer: buyer,
                        consignee_address: consignee_address,
                        remark: remark,
                        price: price,
                        consignee_information: consignee_information,
                    },
                    async: false,
                    dataType: 'json',
                    success: function (result) {
                        console.log(result);
                        if (result.ret) {
                            bool = true;
                        } else {
                            err = result.msg;
                        }
                    }
                });
                if (bool) {
                    this.$message({
                        message: '操作成功',
                        type: 'success'
                    });
                    this.ajaxFunction();
                } else {
                    this.$message({
                        message: err,
                        type: 'error'
                    });
                }
            },
            ajaxFunction() {
                //声明要发送的参数
                var page = this.currentPage;
                var limit = this.pageSize;
                var query = this.keySearch;
                var resultData = '';
                var bool = false;
                var err = "系统异常！";
                $.ajax({
                    url: '/order/getOrderListByPM.json',
                    type: 'post',
                    data: {query: query, page: page, limit: limit},
                    async: false,
                    dataType: 'json',
                    success: function (result) {
                        console.log(result);
                        if (result.ret) {
                            bool = true;
                            resultData = result.data;

                        }
                    }
                });
                if (bool) {
                    this.tableData = resultData.list;
                    this.totalRecords = resultData.count;
                } else {
                    this.$message({
                        message: err,
                        type: 'error'
                    });
                }
            },
        },
        async mounted() {
            this.ajaxFunction();
        }
    })
</script>
</body>

</html>